package com.atstudy.headline.web.admin.controller.statistics;

import com.atstudy.headline.entity.ContentPerformanceDaily;
import com.atstudy.headline.result.Result;
import com.atstudy.headline.web.admin.service.ContentHotScoreService;
import com.atstudy.headline.web.admin.service.ContentPerformanceDailyService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/contentPerformanceDaily")
public class contentPerformanceDailyController {
    @Autowired
    private ContentPerformanceDailyService contentPerformanceDailyService;

    @Autowired
    private ContentHotScoreService contentHotScoreService;

    /**
     * 分页查询用户行为数据
     * @param current 当前页码
     * @param size 每页大小
     * @param contentId 内容ID
     * @param categoryId 分类ID
     * @param authorId 作者ID
     * @return 分页结果
     */
    @GetMapping("/daily/page")
    public Result<IPage<ContentPerformanceDaily>> pageUserBehaviorDaily(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "6") Integer size,
            @RequestParam(required = false) String contentId,
            @RequestParam(required = false) String categoryId,
            @RequestParam(required = false) String authorId) {
        Page<ContentPerformanceDaily> page = new Page<>(current, size);
        IPage<ContentPerformanceDaily> result = contentPerformanceDailyService.pageWithJoin(page, contentId, categoryId, authorId);
        return Result.ok(result);
    }
}